package com.iiapk.gridnew.view;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.iiapk.gridnew.R;

public class DotPoint extends LinearLayout{
	
	private List<ImageView> views = new ArrayList<ImageView>();
	private Context mContext;
	
	public DotPoint(Context context, AttributeSet attrs) {
		super(context, attrs);
		mContext=context;
		setPadding(5, 10, 5, 10);
	}

	public DotPoint(Context context,int size) {
		this(context,null);
		initViewSize(size);
	}
	
	public void initViewSize(int size){
		if(size-2>0){
			for(int i=0;i<size-2;i++){
				ImageView imageView = new ImageView(mContext);
				imageView.setAdjustViewBounds(true);
				imageView.setPadding(5, 0, 5, 0);
				imageView.setImageResource(R.drawable.but_dot);
				views.add(imageView);
				this.addView(imageView);
			}
		}
		setSelectItem(1);
	}
	
	public void setSelectItem(int position){
		for(ImageView imageView:views){
			imageView.setSelected(false);
		}
		views.get(position-1).setSelected(true);
	}

}
